
<template>
    <div class="FooterSetting">
     <div  class="iconbox"  v-for="(item,index) in TipTextBoxs" :key="index">
      <!-- :style="{ '--tooltip-content': item.title }" 动态绑定内容到 CSS 变量 -->
      <!-- :data-tooltip-content="item.title" 动态绑定内容到 data- 属性 -->
      <span  
      :data-tooltip-content="item.title" 
       @mouseover="showTooltip" @mouseout="hideTooltip">
        <i  :class="[item.icon]"></i>
      </span>
    </div>
      
    </div>
  </template>
  <script>

  export default {
    data() {
      return {
    
      TipTextBoxs:[{title:'搜索',icon:"el-icon-zoom-in"},
      {title:'历史记录',icon:"el-icon-time"},
      {title:'设置',icon:"el-icon-s-tools"}],
      
      tooltipVisible: false
      };
    },
    components:{
     
    },
    methods: {
      showTooltip() {
      this.tooltipVisible = true;
    },
    hideTooltip() {
      this.tooltipVisible = false;
    },
    }
  
  }
  </script>
  
  <style scoped>
  .iconbox {
  display: flex;
  height: 44px;
  font-size: 20px;
  align-items: flex-end;
  justify-content: center;
  margin-right: 10px;
}

.iconbox span {
  position: relative;
  
}

.iconbox span::before {
  /* content: var(--tooltip-content); 使用 CSS 变量引用动态的内容  */
  content:attr(data-tooltip-content); /* 使用 data- 属性获取动态的内容 */
  position: absolute;
  right: 125%;
  width: 200%;
  padding: 3px;
  background-color: #000;
  color: #fff;
  text-align: center;
  border-radius: 4px;
  z-index: 1;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
}

.iconbox span:hover::before {
  visibility: visible;
  opacity: 1;
}

  </style>